guint timeout;
GHashTable *handles;
+
+ guint execute_callbacks_idle_id;
+ GSList *callbacks;
};
/* Icon type, supplemented by MIME type
GTK_FILE_INFO_SIZE |
GTK_FILE_INFO_ICON);
-static void gtk_file_system_win32_iface_init (GtkFileSystemIface *iface);
-static void gtk_file_system_win32_finalize (GObject *object);
+static void gtk_file_system_win32_iface_init (GtkFileSystemIface *iface);
+static void gtk_file_system_win32_dispose (GObject *object);
+static void gtk_file_system_win32_finalize (GObject *object);
static GSList * gtk_file_system_win32_list_volumes (GtkFileSystem *file_system);
static GtkFileSystemVolume *gtk_file_system_win32_get_volume_for_path (GtkFileSystem *file_system,
WIN32_FILE_ATTRIBUTE_DATA *wfad,
const char *mime_type);
+static gboolean execute_callbacks_idle (gpointer data);
+
static gboolean fill_in_names (GtkFileFolderWin32 *folder_win32,
GError **error);
static void fill_in_stats (GtkFileFolderWin32 *folder_win32);
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->dispose = gtk_file_system_win32_dispose;
gobject_class->finalize = gtk_file_system_win32_finalize;
}
system_win32->timeout = g_timeout_add_full (0, 1000, check_volumes, system_win32, NULL);
system_win32->handles = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+ system_win32->execute_callbacks_idle_id = 0;
+ system_win32->callbacks = NULL;
}
static void
#endif
g_hash_table_destroy (system_win32->handles);
+ system_win32->handles = NULL;
}
#define GTK_TYPE_FILE_SYSTEM_HANDLE_WIN32 (_gtk_file_system_handle_win32_get_type ())
gobject_class->finalize = _gtk_file_system_handle_win32_finalize;
}
+static void
+gtk_file_system_win32_dispose (GObject *object)
+{
+ GtkFileSystemWin32 *system_win32;
+
+ system_win32 = GTK_FILE_SYSTEM_WIN32 (object);
+
+ if (system_win32->execute_callbacks_idle_id)
+ {
+ g_source_remove (system_win32->execute_callbacks_idle_id);
+ system_win32->execute_callbacks_idle_id = 0;
+
+ /* call pending callbacks */
+ execute_callbacks_idle (system_win32);
+ }
+
+ G_OBJECT_CLASS (gtk_file_system_win32_parent_class)->dispose (object);
+}
+
static void
gtk_file_system_win32_finalize (GObject *object)
{
CALLBACK_VOLUME_MOUNT
};
-static void queue_callback (enum callback_types type, gpointer data);
+static void queue_callback (GtkFileSystemWin32 *system_win32, enum callback_types type, gpointer data);
struct get_info_callback
{
info->error = error;
info->data = data;
- queue_callback (CALLBACK_GET_INFO, info);
+ queue_callback (GTK_FILE_SYSTEM_WIN32 (handle->file_system), CALLBACK_GET_INFO, info);
}
info->error = error;
info->data = data;
- queue_callback (CALLBACK_GET_FOLDER, info);
+ queue_callback (GTK_FILE_SYSTEM_WIN32 (handle->file_system), CALLBACK_GET_FOLDER, info);
}
info->error = error;
info->data = data;
- queue_callback (CALLBACK_CREATE_FOLDER, info);
+ queue_callback (GTK_FILE_SYSTEM_WIN32 (handle->file_system), CALLBACK_CREATE_FOLDER, info);
}
info->error = error;
info->data = data;
- queue_callback (CALLBACK_VOLUME_MOUNT, info);
+ queue_callback (GTK_FILE_SYSTEM_WIN32 (handle->file_system), CALLBACK_VOLUME_MOUNT, info);
}
};
-static guint execute_callbacks_idle_id = 0;
-static GSList *callbacks = NULL;
static gboolean
execute_callbacks_idle (gpointer data)
{
GSList *l;
+ gboolean unref_file_system = TRUE;
+ GtkFileSystemWin32 *system_win32 = GTK_FILE_SYSTEM_WIN32 (data);
GDK_THREADS_ENTER ();
- for (l = callbacks; l; l = l->next)
+ if (!system_win32->execute_callbacks_idle_id)
+ unref_file_system = FALSE;
+ else
+ g_object_ref (system_win32);
+
+ for (l = system_win32->callbacks; l; l = l->next)
{
struct callback_info *info = l->data;
g_free (info);
}
- g_slist_free (callbacks);
- callbacks = NULL;
+ g_slist_free (system_win32->callbacks);
+ system_win32->callbacks = NULL;
+
+ if (unref_file_system)
+ g_object_unref (system_win32);
- execute_callbacks_idle_id = 0;
+ system_win32->execute_callbacks_idle_id = 0;
GDK_THREADS_LEAVE ();
}
static void
-queue_callback (enum callback_types type, gpointer data)
+queue_callback (GtkFileSystemWin32 *system_win32,
+ enum callback_types type,
+ gpointer data)
{
struct callback_info *info;
break;
}
- callbacks = g_slist_append (callbacks, info);
+ system_win32->callbacks = g_slist_append (system_win32->callbacks, info);
- if (!execute_callbacks_idle_id)
- execute_callbacks_idle_id = g_idle_add (execute_callbacks_idle, NULL);
+ if (!system_win32->execute_callbacks_idle_id)
+ system_win32->execute_callbacks_idle_id = g_idle_add (execute_callbacks_idle, system_win32);
}
static GtkFileSystemHandle *
queue_get_folder_callback (callback, handle, GTK_FILE_FOLDER (folder_win32), NULL, data);
/* Start loading the folder contents in an idle */
- folder_win32->load_folder_id =
- g_idle_add ((GSourceFunc) load_folder, folder_win32);
+ if (!folder_win32->load_folder_id)
+ folder_win32->load_folder_id =
+ g_idle_add ((GSourceFunc) load_folder, folder_win32);
return handle;
}